{include file="Public:header2"/}
<body style="min-height: 100%;background-color: #fff">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form onsubmit="return false;">
                        <div class="layui-form" wid100 lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">赠送编号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="card_no" onchange="search_card_no(this.value)" autocomplete="off"  class="layui-input" style="width: 300px">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">赠送数量</label>
                                <div class="layui-input-block">
                                    <input type="text" name="num" value="1" autocomplete="off"  class="layui-input" style="width: 300px">
                                </div>
                            </div>
                            <div class="prize_info" style="display: none">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">奖品名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="prize_title" autocomplete="off"  class="layui-input" style="width: 300px" disabled>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">奖品图片</label>
                                    <div class="layui-input-inline">
                                        <img style="float:left;width:120px;" class="" id="prize_imgurl" src="">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <input type="hidden" name="id" value="{$id}">
                                    <button class="layui-btn" onclick="return check()">确认保存</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
</body>
</html>
<script type="text/javascript">
    layui.use(['layer','form'], function(){

    });

    function search_card_no(value) {
        var url="{:url('/admin/give_goodslist_info')}";
        var $ = layui.$;
        var load=layer.load(2);
        $.post(url,{'card_no':value},function(data){
            layer.close(load);
            if(data.status==1){
                $(".prize_info").show();
                $("#prize_title").val(data.data.title);
                $("#prize_imgurl").attr("src",data.data.imgurl);
            }else{
                $(".prize_info").hide();
            }
        })
    }

    function check(){
        var url="{:url('/admin/give_goodslist')}";
        var $ = layui.$;
        var load=layer.load(2);
        $.post(url,$("form").serialize(),function(data){
            if(data.status==1){
                layer.msg(data.msg,{icon:1,time:1500},function(){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index);
                    parent.location.reload();
                });
            }else{
                layer.msg(data.msg,{icon:2,anim:6,time:1500},function(){
                    layer.close(load);
                });
            }
        })
    }
</script>
